<?php

/**
 * This is the model class for table "form_element_option".
 *
 * The followings are the available columns in table 'form_element_option':
 * @property string $id
 * @property string $form_id
 * @property string $element_id
 * @property integer $position
 * @property integer $option_is_default
 * @property integer $live
 * @property string $option
 */
class FormElementOptionBase extends CActiveRecord
{
	/**
	 * Returns the static model of the specified AR class.
	 * @return FormElementOption the static model class
	 */
	public static function model($className='FormElementOption')
	{
		return parent::model($className);
	}

	/**
	 * @return string the associated database table name
	 */
	public function tableName()
	{
		return 'form_element_option';
	}

	/**
	 * @return array validation rules for model attributes.
	 */
	public function rules()
	{
		// NOTE: you should only define rules for those attributes that
		// will receive user inputs.
		return array(
			array('position, option_is_default, live', 'numerical', 'integerOnly'=>true),
			array('form_id, element_id, option', 'safe'),
			// The following rule is used by search().
			// Please remove those attributes that should not be searched.
			array('id, form_id, element_id, position, option_is_default, live, option', 'safe', 'on'=>'search'),
		);
	}

	/**
	 * @return array relational rules.
	 */
	public function relations()
	{
		// NOTE: you may need to adjust the relation name and the related
		// class name for the relations automatically generated below.
		return array(
		);
	}

	/**
	 * @return array customized attribute labels (name=>label)
	 */
	public function attributeLabels()
	{
		return array(
			'id' => 'ID',
			'form_id' => 'Form',
			'element_id' => 'Element',
			'position' => 'Position',
			'option_is_default' => 'Option Is Default',
			'live' => 'Live',
			'option' => 'Option',
		);
	}

	/**
	 * Retrieves a list of models based on the current search/filter conditions.
	 * @return CActiveDataProvider the data provider that can return the models based on the search/filter conditions.
	 */
	public function search()
	{
		// Warning: Please modify the following code to remove attributes that
		// should not be searched.

		$criteria=new CDbCriteria;

		$criteria->compare('id',$this->id,true);
		$criteria->compare('form_id',$this->form_id,true);
		$criteria->compare('element_id',$this->element_id,true);
		$criteria->compare('position',$this->position);
		$criteria->compare('option_is_default',$this->option_is_default);
		$criteria->compare('live',$this->live);
		$criteria->compare('option',$this->option,true);

		return new CActiveDataProvider(get_class($this), array(
			'criteria'=>$criteria,
		));
	}
}